Skip to content

Initial support for PolyNull - #1813

Draft
msridhar wants to merge 17 commits into
masterfrom
polynull-explicit
Draft

msridhar wants to merge 17 commits into
masterfrom
polynull-explicit

Conversation

@msridhar

@msridhar msridhar commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1616.

Add JSpecify-mode library model support for polymorphic nullness in method signatures. Library model providers can identify top-level or nested parameter and return locations whose nullness must resolve together at each invocation.

Represent the linked nullness with a fresh, nullable-bounded synthetic inference variable for each call. Generate constraints from named arguments, lambdas, method references, and available result target types, and solve these constraints alongside ordinary generic method type-variable inference. Apply the resolved @Nullable or @NonNull qualifier back to every modeled location in the call-site method type. Report a dedicated inference diagnostic when the linked locations impose incompatible constraints.

Initially model Optional.orElseGet and Map.computeIfAbsent, including calls through overriding methods. Extend nested type-path updates to replace types during inference and to preserve wildcard and captured-type structure when applying the resolved qualifier.

Add tests covering named functional-interface arguments, lambdas, method references, var results, assignment targets, inherited models, explicit and inferred generic type arguments, and custom library model providers.

Assisted-by: Codex (GPT-5)

@msridhar

msridhar commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

This change is part of the following stack:

Change managed by git-spice.

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.82297% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.82%. Comparing base (3a11cc4) to head (2811af1).

Files with missing lines Patch % Lines
...ava/com/uber/nullaway/generics/GenericsChecks.java 92.45% 6 Missing and 6 partials ⚠️
.../com/uber/nullaway/generics/PolyNullInference.java 90.21% 3 Missing and 6 partials ⚠️
...m/uber/nullaway/handlers/LibraryModelsHandler.java 94.44% 1 Missing and 3 partials ⚠️
...r/nullaway/librarymodel/NestedTypePathUpdater.java 85.00% 1 Missing and 2 partials ⚠️
...src/main/java/com/uber/nullaway/LibraryModels.java 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1813      +/-   ##
============================================
+ Coverage     87.68%   87.82%   +0.14%     
- Complexity     3458     3531      +73     
============================================
  Files           110      111       +1     
  Lines         11509    11857     +348     
  Branches       2366     2424      +58     
============================================
+ Hits          10092    10414     +322     
- Misses          652      664      +12     
- Partials        765      779      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add some kind of @PolyNull-like support within library models?

1 participant